package com.cgs.springboottes2secrity.vo;

import lombok.Builder;
import lombok.Data;

/**
 * @author cgs
 * @version woNiu 98
 * @date 2023/4/3 16:36
 */
@Data
@Builder
public class ResponseResult<T> {
    private int code;
    private String msg;
    private T data;

    public static <T> ResponseResult<T> success(T t){
        return ResponseResult.<T>builder()
                .code(ResponseCode.SUCCESS.getCode()).msg(ResponseCode.SUCCESS.getMsg()).data(t)
                .build();
    }
    public static <T> ResponseResult<T> success(){
        return ResponseResult.<T>builder()
                .code(ResponseCode.SUCCESS.getCode()).msg(ResponseCode.SUCCESS.getMsg()).data(null)
                .build();
    }
    public static <T> ResponseResult<T> fail(T t){
        return ResponseResult.<T>builder().data(t).build();
    }
    public static <T> ResponseResult<T> fail(){
        return ResponseResult.<T>builder()
                .code(ResponseCode.FAIL.getCode()).msg(ResponseCode.FAIL.getMsg())
                .data(null).build();
    }
    public static <T> ResponseResult<T> noDuty(){
        return ResponseResult.<T>builder()
                .code(ResponseCode.NO_AUTHED.getCode()).msg(ResponseCode.NO_AUTHED.getMsg())
                .data(null).build();
    }
    public static <T> ResponseResult<T> pwdError(){
        return ResponseResult.<T>builder()
                .code(ResponseCode.NO_AUTHED.getCode()).msg(ResponseCode.NO_AUTHED.getMsg())
                .data(null).build();
    }
    public static <T> ResponseResult<T> notFound(String msg){
        return ResponseResult.<T>builder()
                .code(ResponseCode.NOT_FOUND.getCode()).msg(msg)
                .data(null).build();
    }
    public static <T> ResponseResult<T> noLogin(){
        return ResponseResult.<T>builder()
                .code(ResponseCode.NOT_LOGIN.getCode()).msg(ResponseCode.NOT_LOGIN.getMsg())
                .data(null).build();
    }
}
